//
//  PTPromoteView.m
//  PotentialTraining
//
//  Created by Arise on 2018/11/3.
//  Copyright © 2018 admin. All rights reserved.
//

#import "PTPromoteView.h"
#define MAS_SHORTHAND
#define MAS_SHORTHAND_GLOBALS
#import "Masonry.h"

@interface PTPromoteView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *xian;
@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation PTPromoteView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kColor(254, 211, 54);
        self.layer.cornerRadius = 8;
        self.layer.shadowColor = [UIColor blackColor].CGColor;
        //阴影的透明度
        self.layer.shadowOpacity = 0.2;
        //阴影的圆角
        self.layer.shadowRadius = 4.f;
        //阴影偏移量
        self.layer.shadowOffset = CGSizeMake(0,4);
        [self addSubview:self.titleLabel];
        [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(10);
            make.right.equalTo(-10);
            make.top.equalTo(37);
        }];
        [self addSubview:self.xian];
        [self.xian makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(26);
            make.left.equalTo(15);
            make.right.equalTo(-15);
            make.height.equalTo(2);
        }];
        [self addSubview:self.contentLabel];
        [self.contentLabel makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.xian.mas_bottom).offset(15);
            make.left.equalTo(15);
            make.right.equalTo(-15);
        }];
    }
    return self;
}

- (UILabel *)titleLabel{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:39];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

- (UILabel *)xian{
    if (_xian == nil) {
        _xian = [[UILabel alloc]init];
        _xian.lineBreakMode = NSLineBreakByClipping;
        _xian.text = @"--------------------------------------------------------------------------------------------";
        _xian.textAlignment = NSTextAlignmentCenter;
        _xian.textColor = kColor(200, 200, 200);
    }
    return _xian;
}

- (UILabel *)contentLabel{
    if (_contentLabel == nil) {
        _contentLabel = [[UILabel alloc]init];
        _contentLabel.text = @"将此推广码推荐给您的朋友，填写此推广码注册成功后您将获得积分。积分可抵消部分学费。";
        _contentLabel.font = [UIFont systemFontOfSize:16];
        _contentLabel.textAlignment = NSTextAlignmentCenter;
        _contentLabel.textColor = kColor(102, 102, 102);
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}

- (void) configWithPromoteStr:(NSString *)promoteStr{
    self.titleLabel.text = promoteStr ?: @"";
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
